import { Redis } from 'ioredis'

export async function read(url, key) {
    const redis = new Redis(url)
    const kvs = await redis.hgetall(key)
    await redis.psubscribe(`__keyspace@0__:${key}`, (err, count) => {
        if (err) {
            console.error('订阅失败:', err)
        } else {
            console.log(`成功订阅 ${count} 个频道`)
        }
    })
    redis.on('pmessage', (pattern, channel, message) => {
        console.log(`收到消息: ${message}，频道: ${channel}`)
    })
    return kvs
}

export async function name(params) {}
